/* ===================

AX2E (AXESCON XACML 2.0 Engine) is the Java authorization engine, which implements OASIS XACML 2.0 standard.
Copyright (C) 2007 AXESCON LLC

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA


Contact: AXESCON LLC - info{at}axescon.com

 =================== */
/*
 * XML Type:  AttributeSelectorImpl
 * Namespace: urn:oasis:names:tc:xacml:2.0:policy:schema:os
 * Java type: axescon.xacml.model.policy.AttributeSelectorImpl
 *
 * Automatically generated - do not modify.
 */
package axescon.xacml.model.policy.impl;

import axescon.xacml.api.*;
import axescon.xacml.model.ctx.XacmlCtx;
import axescon.xacml.model.shared.attr.AttributeValueHelper;

import java.util.logging.Logger;

/**
 * An XML AttributeSelectorImpl(@urn:oasis:names:tc:xacml:2.0:policy:schema:os).
 * <p/>
 * This is a complex type.
 */
public class AttributeSelectorImpl extends axescon.xacml.model.policy.impl.ExpressionImpl implements axescon.xacml.model.policy.AttributeSelector {

    static final Logger log=Logger.getLogger("axescon.xacml.model.policy.impl.AttributeSelectorImpl");

    private String requestContextPath;

    private String dataType;

    private boolean mustBePresent;

    public String getRequestContextPath() {
        return requestContextPath;
    }

    public void setRequestContextPath(String requestContextPath) {
        this.requestContextPath = requestContextPath;
    }

    public String getDataType() {
        return dataType;
    }

    public void setDataType(String dataType) {
        this.dataType = dataType;
    }

    public boolean isMustBePresent() {
        return mustBePresent;
    }

    public void setMustBePresent(boolean mustBePresent) {
        this.mustBePresent = mustBePresent;
    }
    Class returnDataType;

    public Liquid eval(CtxHandler ch, XacmlCtx req, ExpressionEvaluator pdp) throws ExpressionEvalIndeterminateException {
        return new Liquid(pdp.getAttributeSelectorEvaluator().eval(this, req));
    }     public Class getReturnDataType(FnFactory ff) throws ExpressionEvalIndeterminateException{
        if(returnDataType==null){
            try {
                returnDataType= AttributeValueHelper.getDefault().newArray(dataType,0).getClass();
            } catch (XacmlException e) {
                throw new ExpressionEvalIndeterminateException("attr designator",
                        XacmlException.ERR_CODE_PROCESSING_UNKNOWN_RETURN_ATTRIBUTE_DESIGNATOR,
                e);
            }
        }
        return returnDataType;
    }

}
